var IEMobileMainWindow = GFMainWindow.extend({
	div_id: null,
	this_id: null,
	selection_list: {},
	selection_value: null,
	constructor: function(id,div_id)
	{
//		this.base(id,class_name,x,y,width,height,hidden,content);
		this.selchg_handler = null; //selchg_handler;
		this.div_id = div_id;
		this.this_id = id;

		this.selection_list['Disabled'] = 0;
		this.selection_value = 0;
		this.UpdateWindow();
	},
	UpdateWindow: function()
	{
		var html;
		var obj;

		obj = this.GetMainDiv();

		html = '<table border="1" cellspacing="0" cellpadding="0">';
		html += '<tr>';
		html += '<td>GownFull</td>';
		html += lib.sprintf('<td><select id="%s_Select">',this.this_id);
		for(var key in this.selection_list) {
			if(this.selection_list[key] == null) continue;
			html += lib.sprintf('<option value="%d"%s>%s</option>',this.selection_list[key],(this.selection_value == this.selection_list[key]) ? ' selected="selected"' : '',key);
		}
		html += '</select></td>';
		html += lib.sprintf('<td><input type="text" id="%s_Preedit" readonly="readonly" /></td>',this.this_id);
		html += '</tr>';
		html += '</table>';
		obj.innerHTML = html;
	},
	GetMainDiv: function()
	{
		return document.getElementById(this.div_id);
	},
	GetSelect: function()
	{
		var buf;
		
		buf = document.getElementById(this.obj_id + '_Select');
		if(buf) return buf;
		else return null;
	},
	AddSelectOption: function(text,value,type)
	{
		selection_list[text] = value;
		UpdateWindow();
	},
	ReplaceSelectOption: function(old_value,text,value,type)
	{
		for(var key in this.selection_list) {
			if(this.selection_list[key] == null) continue;
			if(this.selection_list[key] == value) {
				this.selection_list[key] = null;
				break;
			}
		}
		this.selection_list[text] = value;
		UpdateWindow();
	},
	SelectOption: function(value)
	{
		this.selection_value = value;
		UpdateWindow();
	},
	GetPreedit: function()
	{
		var buf;
		
		buf = document.getElementById(this.obj_id + '_Preedit');
		if(buf) return buf;
		else return null;
	},
	ResetPreedit: function()
	{
		var buf;

		buf = this.GetPreedit();
		if(!buf) return false;
		buf.value = '';
	},
	SetPreeditText: function(str)
	{
		var buf;

		buf = this.GetPreedit();
		if(!buf) return false;
		buf.value = str;
	},
	DeletePreedit: function(c)
	{
		var buf,str;

		buf = this.GetPreedit();
		if(!buf) return false;
		str = buf.value;
		str = str.substr(0,str.length - c);
		buf.value = str;
		return true;
	},
	AppendPreedit: function(c)
	{
		var buf,str;

		buf = this.GetPreedit();
		if(!buf) return false;
		buf.value += c;
	},
	SetPreeditInvalid: function()
	{
		var buf,str;

		buf = this.GetPreedit();
		if(!buf) return false;
		buf.value += ' [Wrong]';
	}
});

var IEMobileCandidateListWindow = GFCandidateListWindow.extend({
	div_id: null,
	constructor: function(id,div_id)
	{
		var html,obj;

		this.div_id = div_id;
		obj = this.GetMainDiv();

		html = '<table width="96" border="1" cellspacing="0" cellpadding="0">';
		html += '<tr>';
		html += '<th align="left" colspan="2">Candidates</th>';
		html += '</tr>';
		for(i=1;i<=9;i++) {
			html += '<tr>';
			html += lib.sprintf('<td width="32">%d</td>',i);
			html += lib.sprintf('<td width="64"><input type="text" id="%s_Candidate%d" readonly="readonly" /></td>',id,i);
			html += '</tr>';
		}
		html += '</table>';
		obj.innerHTML = html;
	},
	GetMainDiv: function()
	{
		return document.getElementById(this.div_id);
	},
	GetCandidateObject: function(i)
	{
		return document.getElementById(lib.sprintf("%s_Candidate%d",this.obj_id,i));
	},
	SetCandidate: function(i,str)
	{
		var obj;

		obj = this.GetSelectionObject(i);
		obj.value = str;
	}
});

var IEMobileGownFullBuilder = GownFullBuilder.extend({
	maindiv: null,
	seldiv: null,
	constructor: function(maindiv,seldiv)
	{
		this.maindiv = maindiv;
		this.seldiv = seldiv;
	},
	LoadCSS: function(file)
	{
		return false;
	},
	BuildMainWindow: function(id)
	{
		return new IEMobileMainWindow(id,this.maindiv);
	},
	BuildCandidateListWindow: function(id)
	{
		return new IEMobileCandidateListWindow(id,this.seldiv);
	},
	AttachHandler: function(obj)
	{
		return false;
	}
});
